<?php
$con = mysql_connect("localhost", "root", "");
if(!$con)
{
    die("Nazdarilo se pripojeni: ". mysql_error());
}
//vytvareni databaze
if (mysql_query("CREATE DATABASE school_rs",$con))
  {
  echo "Database vytvorena!";
  }
else
  {
  echo "Chyba pri vytvareni databaze: " . mysql_error();
  }
//vytvareni tabulek
mysql_select_db("school_rs", $con);
$query = "CREATE TABLE  `school_rs`.`articles` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`id_author` INT( 10 ) NOT NULL ,
`id_section` INT( 10 ) NOT NULL ,
`date` DATE NOT NULL ,
`counter` INT( 10 ) NOT NULL ,
`priority` SMALLINT( 5 ) NOT NULL ,
`header` VARCHAR( 255 ) NOT NULL ,
`anotation` TEXT NOT NULL ,
`article` TEXT NOT NULL ,
`note` TEXT NOT NULL ,
`state` TINYINT( 1 ) NOT NULL ,
`pending` TINYINT( 1 ) NOT NULL
) ";
@mysql_query($query);
$query="CREATE TABLE  `school_rs`.`authors` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`login` VARCHAR( 20 ) NOT NULL ,
`password` VARCHAR( 32 ) NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`rights` TINYINT( 4 ) NOT NULL ,
`state` TINYINT( 1 ) NOT NULL
) ";
@mysql_query($query);

$query="CREATE TABLE  `school_rs`.`forums` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`id_article` INT( 10 ) NOT NULL ,
`date` DATE NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`subject` VARCHAR( 255 ) NOT NULL ,
`text` TEXT NOT NULL ,
`notify` TINYINT( 1 ) NOT NULL
) ";
@mysql_query($query);

$query="CREATE TABLE  `school_rs`.`sections` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 50 ) NOT NULL
) ";
@mysql_query($query);

mysql_close($con);


?>
